<template>
	<view>
		<u-navbar :title="title"></u-navbar>
		<view class="wrap">
			<view class="top">
				<view>
					<view class="tit">
						{{sta == 1?'可用余额':sta==3?'星石总额':'幸运币总额'}}
					</view>
					<view class="num">
						{{num}}
					</view>
				</view>
			</view>

			<view class="billbox">
				<view class="title">{{sta == 1?'可余额':sta==3?'星石':'幸运币'}}明细</view>
			</view>
			
			<view class="billList">
				<view class="list" v-for="(item,idx) in list" :key="idx">
					<view class="tit">{{item.create_time}}</view>
					<view class="bill n-flex-row n-justify-between">
						<view>{{item.remarks}}</view>
						<view class="shu" v-if="item.change_type==1">
							+{{item.number}}
						</view>
						<view class="shu" v-if="item.change_type==2">
							-{{item.number}}
						</view>
					</view>
				</view>
			</view>
			<view class="morebtn">
			<button class="btn" v-if="tibtn" @click="$.to('/pagesA/pages/my/withdrawal')">申请提现</button>
			<button class="btn" @click="$.to('/pagesA/pages/my/Topuplucky')" v-if="sta==2">立即充值</button>
				
			</view>
		</view>
		<u-empty text="暂无记录" mode="list" :show="show" margin-top="200"></u-empty>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: '',
				page: 1,
				sta: '',
				num: '0',
				list:[],
				show:true,
				tibtn:false
			}
		},
		// 触底
		onReachBottom() {
			if (this.list.length < this.page * 10) {
				return
			}
			this.page++;
			this.get_money_log(this.sta)
			console.log("触底");
		},
		onLoad(option) {
			this.sta = option.sta
			if(option.tibtn){
				this.tibtn = true
			}
		},
		onShow() {
			// console.log(this.sta,'this.sta');
			this.list = []
			if (this.sta == 1) {
				this.title = "可用余额"
				this.get_money_log(1)
			}else if(this.sta == 3){
				this.title = "星石"
				this.get_money_log(3)
			} else {
				this.title = "幸运币"
				this.get_money_log(2)
			}
		},
		methods: {
			get_money_log(type) {
				this.$http({
					url: "api/member/money_log",
					data: {
						page: this.page,
						type:type,
					}
				}).then(res => {
					console.log(res, '');
					if (res.data.code == 1) {
						if(res.data.data.list.length == 0){
							this.show = true
						}else{
							this.show = false
						}
						this.list = this.list.concat(res.data.data.list);
						this.num = res.data.data.num
						
					}
				}).catch(err => {});
			},
		}
	}
</script>

<style>
	page {
		background-color: #F3F8FC;
	}

	.wrap {
		padding: 20rpx;
		box-sizing: border-box;
		max-height: calc(100vh - 300rpx);
		overflow: hidden;
		overflow-y: auto;
	}

	.top {
		background: url(https://img.50api.cn/dingdang/qh.png);
		background-size: 100%;
		display: flex;
		align-items: center;
		text-align: center;
		height: 200rpx;
		justify-content: center;
		color: #fff;
	}

	.num {
		font-weight: bold;
		font-size: 46rpx;
		margin-top: 20rpx;
	}

	.billbox {
		margin-top: 20rpx;
	}
	.billList .list{
		margin-top: 10rpx;
		background-color: #fff;
		border-radius: 4rpx;
		padding: 20rpx;
		box-sizing: border-box;
	}
	.list .tit{
		padding-bottom: 20rpx;
		border-bottom: 1rpx solid #efefef;
	}
	.bill{
		padding: 30rpx 0 10rpx;
	}
	.bill .shu{
		color: #05B2B5;
		font-weight: bold;
	}
	.morebtn{
		width: 100%;
		display: flex;
		position: absolute;
		left: 0;
		bottom: 40rpx;
	}
	.btn {
		width: 300rpx;
		background-color: #2AC2B3;
		color: #fff;
	}
</style>
